package com.qfedu.yanglao20admin.advertising.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qfedu.yanglao20.common.CommonResult;
import com.qfedu.yanglao20.entity.advertising.AdvertisingType;
import com.qfedu.yanglao20admin.advertising.param.AdvertisingTypeParam;
import com.qfedu.yanglao20admin.advertising.service.AdvertisingTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "广告类型")
@RestController
@RequestMapping("/AdvertisingType")
public class AdvertisingTypeController {

    @Resource
    private AdvertisingTypeService advertisingTypeService;

    @ApiOperation(value = "展示广告类型数据", notes = "展示广告类型数据")
    @GetMapping("/list")
    public CommonResult<AdvertisingTypeParam> advertisingTypeList(AdvertisingTypeParam param) {
        Page<AdvertisingType> advertisingTypePage = advertisingTypeService.pageAdvertisingType(param);
        return CommonResult.success(advertisingTypePage);
    }

    @ApiOperation(value = "根据id查询广告类型信息", notes = "根据id查询广告类型信息")
    @GetMapping("/query")
    public CommonResult queryById(Integer id) {
        AdvertisingType advertisingType = advertisingTypeService.queryAdvertisingType(id);
        return CommonResult.success(advertisingType);
    }

    @ApiOperation(value = "添加广告类型信息", notes = "添加广告类型信息")
    @PostMapping("/add")
    public CommonResult addAdvertisingType(AdvertisingType advertisingType) {
        advertisingTypeService.add(advertisingType);
        return CommonResult.success();
    }

    @ApiOperation(value = "更新广告类型信息", notes = "更新广告类型信息")
    @PostMapping("/update")
    public CommonResult updateAdvertisingType(AdvertisingType advertisingType) {
        advertisingTypeService.update(advertisingType);
        return CommonResult.success();
    }

    @ApiOperation(value = "根据id删除广告类型信息", notes = "根据id删除广告类型信息")
    @GetMapping("/delete")
    public CommonResult deleteAdvertisingType(Integer id) {
        advertisingTypeService.deleteById(id);
        return CommonResult.success();
    }
}
